(* driver.mli
 *
 * This file is part of camEngine
 * 
 * camEngine - A 3d motor for ocaml
 * Copyright (C) 2009 DAVY Guillaume <davyg2@gmail.com>
 *
 * camEngine is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * camEngine is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with camEngine.  If not, see <http://www.gnu.org/licenses/>.
 *)

open Vec2d;;
open Vec3d;;
open Scanf;;
open Scanning;;
open Mesh;;
open Graphics;;
open Matrice;;

val black : color
val white : color
val red : color
val green : color
val blue : color
val yellow : color
val cyan : color
val magenta : color

class driver :
	object
	(* TODO: Arbital value corresponding to the factor by what is multiply the coordinate of all the point before being drawn*)
	val mutable zoom : float
	(* Matrix whose size correspond to the one of the window containing the distance of the point actually drawn at that position*)
	val mutable zbuffer : float array array
	
	(*Create the important things like the window*)
	method init : vec2d ->  vec2d -> string -> unit
	(*Close the ilmportant things create in init*)
	method close : unit
	
	(* Must be call before any call to draw methods*)
	method preRender : unit
	(* Must be call after all draw methods have been called*)
	method postRender : unit
	
	(* Draw a point and fill the z-buffer*)
	method plot : vec3d -> int -> unit
	method line : vec3d -> vec3d -> int -> unit
	(* TODO: Draw a face, call the graphics function but you chould write our own function to include zbuffer*)
	(*method face : (vec2d * vec2d * vec2d) -> int -> float -> unit*)
	
	(* Project a 3d point to the 2d plan*)
	method project : vec3d -> vec2d
	(* Project a 3d triangle to the 2d plan*)
	method projTri : (vec3d*vec3d*vec3d)-> (vec2d*vec2d*vec2d)
	
	(* Draw a 3d triangle*)
	method drawFace : (vec3d*vec3d*vec3d) -> int -> unit
	(* Draw many 3d triangle from a set of point and a set of corresponding indices*)
	method drawFaces : (vec3d array) -> ((int * int * int * int) list) -> unit
	
	(* Open a file to read*)
	method openFile : string -> scanbuf
	(* Open a mesh from his path*)
	method getMesh : string -> mesh
	
	(* Set the far value(for the zbuffer)*)
	method set_far : float -> unit
	(* Return the far value(for the zbuffer)*)
	method get_far : float
	
	(* Set the world matrix*)
	method set_world : matrice4 -> unit
	(* Set the view matrix*)
	method set_view : matrice4 -> unit
	(* Set the projection matrix*)
	method set_projection : matrice4 -> unit
	
	(* Return the world matrix*)
	method get_world : matrice4
	(* Return the transform matrix*)
	method get_view : matrice4
	(* Return the transform matrix*)
	method get_projection : matrice4
	
	(* Set the window title*)
	method set_title : string -> unit
	
	(* TODO: Permit to see what is draw else it's too small, must be deleted when camera will be support*)
	method private fit : (vec2d) -> unit
	(* Clear the window*)
	method private clear : unit
	(* Read and interpret a buf containing .obj file*)
	method private readObj : scanbuf -> (string* vec3d array * (int*int*int) list)
	(* Return the size of the window*)
	method private get_size : vec2d
end;;

